package com.face.receive.jsu;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.json.JSONObject;

import com.face.operate.jsu.Prestore;

//更新集合
@WebServlet("/UpdatePrestore")
public class UpdatePrestore extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		int id = Integer.parseInt(request.getParameter("id"));
		String phone_num = request.getParameter("phone_num");
		String name = request.getParameter("name");
		Prestore prestore = new Prestore();
		prestore.update(id,phone_num,name);
		prestore.updatePicture(id,phone_num);
		
		JSONObject json = new JSONObject();
		try {
			json.put("message", "ok");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		response.setContentType("application/json; charset=utf-8");
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(json.toString());
		System.out.println("返回的json数据：" + json.toString());
	}


}
